import { Badge } from '/components/badge'

# File Upload Configuration

This section is used to configure file upload settings, including allowed file types and file size limits. For methods of file uploading and file deletion, please refer to the [Methods](/en/docs/events).

## Default Configuration

```js
{
  file: {
    allowedMimeTypes: [],
    maxSize: 1024 * 1024 * 100, // 100MB
    preview: [ // New in v5.0.0
      { extensions: ['pdf'], url: '{url}' },
      {
        extensions: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
        url: 'https://view.officeapps.live.com/op/embed.aspx?src={{url}}&amp;wdStartOn=1&amp;wdPrint=0&amp;wdEmbedCode=0',
      },
    ],
  },
}
```

## Configuration Item Descriptions

### file.allowedMimeTypes

**Description**: The allowed file types for upload. An empty array indicates that all file types are allowed.

**Type**: `Array`

**Default**: `[]`.

**Options**:

Valid [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) values.

Additionally, to upload files of the same type, you can use the * wildcard for simplified configuration. For example, to allow the upload of all image files, it can be configured as `['image/*']`.

### file.maxSize

**Description**: The maximum size allowed for uploaded files, in bytes (B).

**Type**: `Number`.

**Default**: `1024 * 1024 * 100` (100M)

### file.preview 

**Description**: Preview file configuration, including file type and preview link, note that modifying this value will directly override the default value, if you need to adjust the preview file configuration, please make changes based on the default value. <Badge theme="success">New in v5.0.0</Badge>

**Type**: `Array`

**Default**:
```js
[
  { extensions: ['pdf'], url: '{url}' },
  {
    extensions: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
    url: 'https://view.officeapps.live.com/op/embed.aspx?src={{url}}&amp;wdStartOn=1&amp;wdPrint=0&amp;wdEmbedCode=0',
  },
]
```

**Optional Values**:

- `preview[].extensions`: The supported file suffix array, refer to the default value.
- `preview[].url`: The preview link, which can be a string or an array of strings, supporting `{url}` and `{{url}}` placeholders for replacing the uploaded file URL and performing encodeURIComponent encoding, respectively.